﻿// Developer Express Code Central Example:
// World Wide CRM Demo
// 
// The World Wide CRM demo is a next generation application with outstanding
// navigation capabilities and shows a reimagined view of customer contact and
// management. This demo showcases many of the most popular features of the
// WinForms Subscription.
// 
// You can find sample updates and versions for different programming languages here:
// http://www.devexpress.com/example=E3993

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.CrmDemo.Win.Data;
using DevExpress.CrmDemo.Win.Helpers;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Drawing;

namespace DevExpress.CrmDemo.Win.Controls {
    public partial class SchedulerPage : BasePage {
        public SchedulerPage() {
            InitializeComponent();
        }

        public SchedulerPage(CustomEventList appointments, IList<TeamMember> teamMembers)
            : this() {
            Appointments = appointments;
            TeamMembers = teamMembers;
        }

        public CustomEventList Appointments { get; set; }
        public IList<TeamMember> TeamMembers { get; set; }

        private void header1_BackRequest(object sender, EventArgs e) {
            OnNavRequest(new NavRequestEventArgs(States.Dashboard));
        }

        private void SchedulerPage_Load(object sender, EventArgs e) {
            schedulerControl1.BeginUpdate();
            this.schedulerControl1.Appearance.Appointment.ForeColor = ColorHelper.LabelColor;
            schedulerControl1.Start = DateTime.Now;
            schedulerControl1.WorkWeekView.TopRowTime = TimeSpan.FromHours(8);

            this.schedulerStorage1.Appointments.DataSource = Appointments;
            this.schedulerStorage1.Resources.DataSource = TeamMembers;

            schedulerControl1.EndUpdate();
        }

        private void schedulerControl1_VisibleIntervalChanged(object sender, EventArgs e) {
            labelDateRange.Text = dateNavigator1.SelectionStart.GetDateRangeString(dateNavigator1.SelectionEnd);
        }

        private void pictureBoxNavBack_Click(object sender, EventArgs e) {
            schedulerControl1.Services.DateTimeNavigation.NavigateBackward();
        }

        private void pictureBoxNavForward_Click(object sender, EventArgs e) {
            schedulerControl1.Services.DateTimeNavigation.NavigateForward();
        }
    }
}